package com.xh.rabbit_pay.controller;

import com.xh.rabbit_pay.dao.PayDao;
import com.xh.rabbit_pay.entity.Pay;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class PayController {

    @Autowired
    private PayDao payDao;

    @RequestMapping("/pay/{payId}")
    public String pay(@PathVariable Integer payId, Model model) {

        // 写数据库
        Pay pay = payDao.findCode(payId);
        pay.setStatus("1");
        pay.setRemark("已支付");
        payDao.upDate(pay);
        model.addAttribute("payId", payId);
        return "success";
    }

}
